<?php


class mod_get_mblog_by_token 
{
	public $api_debug = false;
	
	function mod_get_mblog_by_token($app_id=0)
	{
		
		switch ($app_id)
		{
			//这里请修改成各站自己的appkey,如果不清楚联系 杨超（15801014145）
			case 444551:
			$this->app_key = "7e1b4a5001a9009d3f80d9ffe2d836fd";
			$this->app_secret = "8a85b23661f96e9356dbaf3212589fa9";
			$this->app_id = "444551";
			break;
			
			default;
       	 	$this->app_key = "7e1b4a5001a9009d3f80d9ffe2d836fd";
			$this->app_secret = "8a85b23661f96e9356dbaf3212589fa9";
			$this->app_id = "444551";
   		 	break;
   		 	

		}
		
		if(isset($_GET["api_debug"]))
		{
			$this->api_debug = true;
		}
		else
		{
			$this->api_debug = false;
		}
	}
	
	
	// 性能分析
	private function perf_add_count($url)
	{
		global $mblog_performance_wapi_called_count;
		$mblog_performance_wapi_called_count[] = $url;
	}
	
	//获取
	public function perf_get_count()
	{
		global $mblog_performance_wapi_called_count;
		return count($mblog_performance_wapi_called_count);
	}
	
	//输出
	private function debug_echo($url)
	{
		$count = $this->perf_get_count();
		$str = "<!-- NO:{$count} {$url} -->"; 
		echo $str . "\n";
	}	
		
	function mblog_curl_request($api_url, $submit_ary, $debug)
	{
		
		$content = network::curl_submit($api_url, $submit_ary,  $this->api_debug);
		
		return $content;
	}
	
	
########################共有接口	
	//本地测试的时候这样用
	function api_get_filtered_by_token($token,$p=1,$pcount=10,$trim_status=1)
	{

		$api_url = MBLOGV2_DEMAIN."/api/tcommonv2/token_auth/api_get_filtered_by_token.php";
		$submit_ary["ip_debug"] = 1;
		$submit_ary["token"] = $token;
		$submit_ary["p"] = $p;
		$submit_ary["pcount"] = $pcount;
		$submit_ary["trim_status"] = $trim_status;
		$submit_ary["t"] = "json";
		$submit_ary["app_key"] = $this->app_key;
		$submit_ary["app_secret"] = $this->app_secret;
		$submit_ary["app_id"] = $this->app_id;
		$content = $this->mblog_curl_request($api_url, $submit_ary,  $this->api_debug);
		$content = json_decode($content,true);
		if($this->api_debug)
		{
			print_r($content);
		}
		return $content;
	}

	
	function api_get_blocking_by_token($token,$p=1,$pcount=10,$trim_status=1)
	{
		$api_url = MBLOGV2_DEMAIN."/api/tcommonv2/token_auth/api_get_blocking_by_token.php";
		$submit_ary["ip_debug"] = 1;
		$submit_ary["token"] = $token;
		$submit_ary["p"] = $p;
		$submit_ary["pcount"] = $pcount;
		$submit_ary["t"] = "json";
		$submit_ary["app_key"] = $this->app_key;
		$submit_ary["app_secret"] = $this->app_secret;
		$submit_ary["app_id"] = $this->app_id;
		$content = $this->mblog_curl_request($api_url, $submit_ary,  $this->api_debug);
		$content = json_decode($content,true);
		if($this->api_debug)
		{
			print_r($content);
		}
		return $content;
	}
	
	
	function api_add_blocking_by_token($token,$uid)
	{
		$api_url = MBLOGV2_DEMAIN."/api/tcommonv2/token_auth/api_add_blocking_by_token.php";
		$submit_ary["ip_debug"] = 1;
		$submit_ary["token"] = $token;
		$submit_ary["uid"] = $uid;
		$submit_ary["t"] = "json";
		$submit_ary["app_key"] = $this->app_key;
		$submit_ary["app_secret"] = $this->app_secret;
		$submit_ary["app_id"] = $this->app_id;
		$content = $this->mblog_curl_request($api_url, $submit_ary,  $this->api_debug);
		$content = json_decode($content,true);
		if($this->api_debug)
		{
			print_r($content);
		}
		return $content;
	}
	
	/**
	 * 举报
		url 	true 	string 	举报url。
		content 	true 	string 	举报内容，必须做URLEncode，采用UTF-8编码。
		ip 	true 	string 	举报者ip，必以 : 1.1.1.1 为格式。
		type 	false 	int 	默认4。取值为：1:博客，2：评论，3：用户，4：其他，5：群组，6：群微博，7：群评论，8：相册，9：相片，10：相册/相片的评论，11：私信，12：群长文本，13：精选集。
		rid 	false 	string 	对应举报类型的ID。当type不为4时，rid必须有值。例：当type为1时 rid需要传微博的id，type为3 时，rid传用户的uid，以此类推。
		class_id 	false 	int 	举报内容类型， 值为：1.垃圾广告 2. 色情 3.其他， 4.身份造假，5 不实信息，6 人身攻击，7 泄露个人隐私，默认为3。
	 */
	function api_add_spam_by_token($token,$url,$content,$ip,$type,$rid,$class_id)
	{
		$api_url = MBLOGV2_DEMAIN."/api/tcommonv2/token_auth/api_add_spam_by_token.php";
		$submit_ary["ip_debug"] = 1;
		$submit_ary["token"] = $token;
		$submit_ary["t"] = "json";
		$submit_ary["url"] = $url;
		$submit_ary["content"] = $content;
		$submit_ary["ip"] = $ip;
		$submit_ary["type"] = $type;
		$submit_ary["rid"] = $rid;
		$submit_ary["class_id"] = $class_id;
		
		
		$submit_ary["app_key"] = $this->app_key;
		$submit_ary["app_secret"] = $this->app_secret;
		$submit_ary["app_id"] = $this->app_id;
		$content = $this->mblog_curl_request($api_url, $submit_ary,  $this->api_debug);
		$content = json_decode($content,true);
		if($this->api_debug)
		{
			print_r($content);
		}
		return $content;
	}
	

	
}

###############################测试数据



